import {debounce} from './utils.js'
import backTop from "components/content/backTop/backTop";

export const imgsLoadMixin = {
	data() {
		return {
			imgsLoad: null,
			offsetTops: [0],
			getOTops: null
		}
	},
	mounted() {
		this.imgsLoad = debounce(this.$refs.scroll.refresh, 100)
		if(this.getOffsetTops)
		this.getOTops = debounce(this.getOffsetTops, 100)
		//  接收判断事件总线的事件
		this.$bus.$on('loadImg', () => {
			this.imgsLoad()
			this.getOTops && this.getOTops()
		})
	}
}

export const backTopMixin = {
	components: {
		backTop,
	},
	data() {
		return {
			show: false,
		}
	},
	methods:{
		clickTop() {
			this.$refs.scroll.scrollTo(0,0,500)
		},
		listenShow(position) {
			this.show = position.y <  -1000
		}
	}
	
}